package com.wksc.authority.service;

import com.wksc.authority.dao.SysAuthorityGroupDao;
import com.wksc.authority.model.SysAuthorityGroup;
import com.wksc.framework.message.BaseMessage;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * 权限组service
 *
 * @author Zero
 */
@Service
public class SysAuthorityGroupService {
    @Autowired
    private SysAuthorityGroupDao authorityGroupDao;

    /**
     * 保存权限组信息
     *
     * @param group 权限组对象
     * @return true：成功，false：失败
     */
    public BaseMessage saveAuthorityGroup(SysAuthorityGroup group) {
        authorityGroupDao.saveAuthorityGroup(group);
        return BaseMessage.successMsg("保存权限组信息成功！");
    }

    /**
     * 修改权限组信息
     *
     * @param group 权限组对象
     * @return true：成功，false：失败
     */
    public BaseMessage updateAuthorityGroup(SysAuthorityGroup group) {
        authorityGroupDao.updateAuthorityGroup(group);
        return BaseMessage.successMsg("修改权限组信息成功！");
    }

    /**
     * 删除权限组信息
     *
     * @param ids 权限组id数组
     * @return true：成功，false：失败
     */
    public BaseMessage deleteAuthorityGroup(long[] ids) {
        if (null == ids) {
            throw new NullPointerException("删除的权限组id列表不能为空");
        }
        for (long id : ids) {
            authorityGroupDao.deleteAuthorityGroup(id);
        }
        return BaseMessage.successMsg("删除权限组信息成功！");
    }

}
